package com.ruoyi.system.domain.wrapper.view;

import cn.hutool.core.bean.BeanUtil;
import com.eic.framework.core.domain.BaseEntityWrapperV;
import com.ruoyi.system.domain.dao.SysDictData;
import com.ruoyi.system.domain.view.SysDictDataVo;

/**
 * 字典数据前端实体包装
 *
 * @author 尹国春
 * @date 2022-07-22
 */
public class SysDictDataWrapperV extends BaseEntityWrapperV<SysDictData, SysDictDataVo> {

    private static SysDictDataWrapperV wrapperV=null;
    //示例代码
    //private static IDemoDeptService demoDeptService;
    private SysDictDataWrapperV(){
    }

    public static SysDictDataWrapperV build(){
        if(wrapperV==null){
            //示例代码
            //demoDeptService= SpringUtils.getBean(IDemoDeptService.class);
            //Assert.notNull(demoDeptService);
            wrapperV=new SysDictDataWrapperV();
        }
        return wrapperV;
    }

    @Override
    public SysDictDataVo entityVO(SysDictData entity) {
        if(entity==null){
            return new SysDictDataVo();
        }
        SysDictDataVo vo = BeanUtil.copyProperties(entity,SysDictDataVo.class);
        //示例代码
        //vo.setDeptName(getFieldValue(demoDeptService,entity.getDeptId(),DemoDept::getDepartName));
        return vo;
    }

    /*示例代码
    @Override
    public List<SysDictDataVo> listVO(List<SysDictData> list) {
        List<SysDictDataVo> voList=list.stream().map(user -> BeanUtil.copyProperties(user,SysDictDataVo.class)).collect(Collectors.toList());
        copyForeignKeyData(voList,SysDictDataVo::getDeptId,SysDictDataVo::setDeptName,demoDeptService,DemoDept::getDepartName);
        return voList;
    }
    */
}